﻿$(function () {
    $('#siteheader #headsearchbutton').click(DoHeaderSearch);
    $('#headersearchresultcontainer').dialog({
        autoOpen: false,
        height: 'auto',
        width: 500,
        modal: true,
        resizable: false,
        draggable: false,
        buttons: {
            "关闭": function () {
                $(this).dialog('close');
            }
        }
    });

    $('#siteheader #headersearchtext').Watermark("姓名、昵称、Email").keydown(function (event) {
        if (event.keyCode == '13') {
            event.preventDefault();
            DoHeaderSearch();
        }
    });
});

function DoHeaderSearch() {
    var keyword = $.trim($('#siteheader #headersearchtext').val());
    if (keyword != "姓名、昵称、Email" && keyword != '') {

        $('#headersearchresult').empty();
        $('#shs-c').remove();
        $('#headersearchresult').load(relRootPath + '/Mod/orphans/UserSearchResult.aspx #hs-result',
            { keyword: keyword, page : 1 },
        GetResult
         );
    }
}

function GetResult(d, s, x) {
    $.getScript(relRootPath + "/Scripts/UserSearchResult.js?t=" + new Date(), function () {
        $('#headersearchresultcontainer').dialog('open');
        avl.hide();
    });
}